<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>释放所有的会话变量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.session-status.html">« session_status</a></li>
      <li style="float: right;"><a href="function.session-write-close.html">session_write_close »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.session.html">Session 函数</a></li>
    <li>释放所有的会话变量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.session-unset" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">session_unset</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">session_unset</span> &mdash; <span class="dc-title">释放所有的会话变量</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.session-unset-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>session_unset</strong></span>(): <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>session_unset()</strong></span> 会释放当前会话注册的所有会话变量。
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.session-unset-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.session-unset-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    如果使用的是 <var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var> (或者PHP 4.0.6或更早版本的 <var class="varname">$HTTP_SESSION_VARS</var>
    ) ，请使用 <span class="function"><a href="function.unset.html" class="function">unset()</a></span> 去
    注销会话变量，即
    <code class="literal">unset ($_SESSION[&#039;varname&#039;]);</code>.
   </p>
  </p></blockquote>
  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    请不要使用<code class="literal">unset($_SESSION)</code>来释放整个<var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var>，
    因为它将会禁用通过全局<var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var>去注册会话变量
   </p>
  </div>
 </div>


</div></div></div></body></html>